package com.common.kankan.wheel.widget;

import java.util.Calendar;
import java.util.Locale;

/**
 * 标识范围
 * 
 * @author pengxh
 * 
 */
public class Range {
	/**
	 * 开始
	 */
	public int start = -1;

	/**
	 * 结束
	 */
	public int end = -1;

	/**
	 * 当前
	 */
	public int currItem = -1;

	/**
	 * 
	 * @param start
	 *            最小值
	 * @param end
	 *            最大值
	 * @param field
	 *            标识当前适配器给谁使用（年、月、日）
	 */
	public Range(int start, int end, int field) {
		super();
		this.start = start;
		this.end = end;

		Calendar calendar = Calendar.getInstance(Locale.CHINA);

		switch (field) {
		case Calendar.YEAR:
			int curYear = calendar.get(Calendar.YEAR);
			this.currItem = curYear - start;
			break;
		case Calendar.MONTH:
			int curMonth = calendar.get(Calendar.MONTH);
			this.currItem = curMonth - start + 1;
			break;
		case Calendar.DAY_OF_MONTH:
			int curDay = calendar.get(Calendar.DAY_OF_MONTH);
			this.currItem = curDay - start;
			break;

		default:
			break;
		}
	}

	@Override
	public String toString() {
		return "Range [start=" + start + ", end=" + end + ", currItem=" + currItem + "]";
	}
}
